Skip to content

fix: add env.error shim for yeoman-environment v4 backwards compatibility - #76

Merged
shazron merged 2 commits into
mainfrom
copilot/fix-typeerror-env-error-function
Apr 28, 2026
Merged

fix: add env.error shim for yeoman-environment v4 backwards compatibility#76
shazron merged 2 commits into
mainfrom
copilot/fix-typeerror-env-error-function

Conversation

Copilot AI commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Fixes #75

yeoman-environment v4 removed the env.error() method present in v3. Generators like @adobe/generator-app-common-lib's ActionGenerator call this.env.error() in their constructors, producing TypeError: this.env.error is not a function instead of the intended error message.

Changes

  • src/commands/templates/install.js — After yeoman.createEnv(), conditionally attach an env.error shim that mirrors the v3 behaviour:

    if (typeof env.error !== 'function') {
      env.error = (err) => { throw err instanceof Error ? err : new Error(err) }
    }

    The guard means the shim is a no-op if a future yeoman-environment version restores the method.

  • test/commands/templates/install.test.js

    • beforeEach now deletes createEnvReturnValue.error to prevent shim state from leaking across tests.
    • New test exercises the shim function body (both ternary branches: plain string and Error instance).
    • New test asserts the shim is skipped when the env already exposes error.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • scarf.sh
    • Triggering command: /usr/local/bin/node node ./report.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI linked an issue Apr 27, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix TypeError when instantiating ActionGenerator fix: add env.error shim for yeoman-environment v4 backwards compatibility Apr 27, 2026
Copilot AI requested a review from shazron April 27, 2026 09:43
@codecov

codecov Bot commented Apr 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@shazron
shazron marked this pull request as ready for review April 27, 2026 10:19
@shazron
shazron merged commit 83446a2 into main Apr 28, 2026
9 checks passed
@shazron
shazron deleted the copilot/fix-typeerror-env-error-function branch April 28, 2026 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError: this.env.error is not a function

3 participants